//
//  ViewController.m
//  aa
//
//  Created by IOS_wt on 15/11/30.
//  Copyright © 2015年 wangteng. All rights reserved.
//

#import "ViewController.h"
#import "MyTableViewCell.h"
@interface ViewController ()
{
    UITableView * _tableView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self->_tableView=[[UITableView alloc]init];
    self->_tableView.translatesAutoresizingMaskIntoConstraints=NO;
    [self.view addSubview:self->_tableView];
    // 设置为一个接近“平均”行高的值
    self->_tableView.estimatedRowHeight = 44.0;
    self->_tableView.rowHeight = UITableViewAutomaticDimension;
    
    NSArray *constraints1=[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_tableView]|"options:0 metrics:nil views:@{@"_tableView":self->_tableView}];
    [self.view addConstraints:constraints1];
    
    NSArray *constraints2=[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-30-[_tableView]|"options:0 metrics:nil views:@{@"_tableView":self->_tableView}];
    [self.view addConstraints:constraints2];
    
    self->_tableView.dataSource=self;
    self->_tableView.delegate=self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
////    MyTableViewCell *cell=[self tableView:self.myTableView cellForRowAtIndexPath:indexPath];
////    if (cell.frame.size.height<44) {
////        return 44;
////    }
////    return cell.myLable.frame.size.height;
//    
//    
//
//}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *cellID = @"cell";
    
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (cell == nil) {
        cell = [[MyTableViewCell alloc] init];
    }
    
    [cell awakeFromNib];
    cell.backgroundColor=[UIColor yellowColor];
    return  cell;
    
    
}

//-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//    return UITableViewAutomaticDimension+30;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
